Fix Windows MSVC build failure during ABI generation#388
Draft
Fix Windows MSVC build failure during ABI generation#388
Conversation
Co-authored-by: r-near <163825889+r-near@users.noreply.github.com>
Co-authored-by: r-near <163825889+r-near@users.noreply.github.com>
Co-authored-by: r-near <163825889+r-near@users.noreply.github.com>
Co-authored-by: r-near <163825889+r-near@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Windows build failure during ABI generation
Fix Windows MSVC build failure during ABI generation
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo near buildfails on Windows with 55 unresolved external symbol linker errors (LNK2019) during ABI generation. The build succeeds with--no-abi.Root Cause
ABI generation compiles the contract as a native dylib with
near-sdk/__abi-generate. The near-sys crate declares NEAR runtime functions (read_register,register_len, etc.) asextern "C"- these are provided by the NEAR VM in wasm builds but don't exist in native builds. MSVC's linker rejects unresolved symbols by default, unlike Linux/macOS dynamic linkers.Changes
Add Windows linker flag: Pass
/FORCE:UNRESOLVEDto MSVC linker when building ABI dylib, allowing unresolved symbols (safe since the dylib is only loaded for symbol extraction, never executed)Fix RUSTFLAGS handling: Refactor
cargo_native::compile::runto append-Awarningsto existing RUSTFLAGS instead of replacing them, ensuring Windows linker flag is preservedThe dylib is temporary and only used for ABI extraction via
libloading- unresolved symbols never cause runtime issues.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
s3-us-west-1.amazonaws.com/home/REDACTED/work/cargo-near/cargo-near/target/debug/build/near-workspaces-a8b4a713a403149e/build-script-build /home/REDACTED/work/cargo-near/cargo-near/target/debug/build/near-workspaces-a8b4a713a403149e/build-script-build --gdwarf-4 --64 --noexecstack -o crypto/x509/libcrypto-lib-v3_bitst.o /tmp/cccbl4ru.s /usr/sbin/cc AES_ASM -DECP_NIas /home/REDACTED/wor-I(dns block)/home/REDACTED/work/cargo-near/.codeql-scratch/dbs/rust/working/target/debug/build/near-workspaces-2094825312d8cd28/build-script-build /home/REDACTED/work/cargo-near/.codeql-scratch/dbs/rust/working/target/debug/build/near-workspaces-2094825312d8cd28/build-script-build - -o /rust/working/ta-I N /rust/working/ta--gdwarf-4 .o cal/bin/cc 6e14519a1242e/oucc -gdwarf-4 -fno-omit-frame--c /rust/working/ta-o -O0 rget/debug/build-x rget/debug/buildassembler rget/debug/build/dev/null rget/debug/build/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/rustc rget/debug/build--crate-name pointer as(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.